import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class Checkinobj {

  final int? id;

  final int? items;

  final int? containers;

  final int? order;

  @JsonKey(name: 'order_info')
  final OrderInfo? orderInfo;

  @JsonKey(name: 'shipment_code')
  final String? shipmentCode;

  @JsonKey(name: 'carrier')
  final String? carrier;

  @JsonKey(name: 'pro_number')
  final String? proNumber;

  @JsonKey(name: 'bol_number')
  final String? bolNumber;

  @JsonKey(name: 'seal_number')
  final String? sealNumber;

  @JsonKey(name: 'trailer_number')
  final String? trailerNumber;

  final String? scac;

  @JsonKey(name: 'checkin_time')
  final String? checkinTime;

  final String? warehouse;

  Checkinobj({

    this.id,

    this.items,

    this.containers,

    this.order,

    this.orderInfo,

    this.shipmentCode,

    this.carrier,

    this.proNumber,

    this.bolNumber,

    this.sealNumber,

    this.trailerNumber,

    this.scac,

    this.checkinTime,

    this.warehouse,

  });

  factory Checkinobj.fromJson(Map<String, dynamic> json) {
    print('-----:{$json}');
    return Checkinobj(

      id: json['id'] as int?,

      items: json['items'] as int?,

      containers: json['containers'] as int?,

      order: json['order'] as int?,

      orderInfo: json['order_info'] != null ? OrderInfo.fromJson(json['order_info']) : null,

      shipmentCode: json['shipment_code'] as String?,

      carrier: json['carrier'] as String?,

      proNumber: json['pro_number'] as String?,

      bolNumber: json['bol_number'] as String?,

      sealNumber: json['seal_number'] as String?,

      trailerNumber: json['trailer_number'] as String?,

      scac: json['scac'] as String?,

      checkinTime: json['checkin_time'] as String?,

      warehouse: json['warehouse'], 

    );

  }

  Map<String, dynamic> toJson() => {
    'id': id?.toString(),
    'items': items?.toString(),
    'containers': containers?.toString(),
    'order': order?.toString(),
    'shipment_code': shipmentCode,
    'carrier': carrier,
    'pro_number': proNumber,
    'bol_number': bolNumber,
    'seal_number': sealNumber,
    'trailer_number': trailerNumber,
    'scac': scac,
    'checkin_time': checkinTime,
    'warehouse': warehouse?.toString(),
  };
  

}

@JsonSerializable()
class OrderInfo{
  
  final int? id;

  @JsonKey(name: 'order_number')
  final String? orderNumber;

  OrderInfo({

    this.id,

    this.orderNumber,
  });
  factory OrderInfo.fromJson(Map<String, dynamic> json) {

    return OrderInfo(

    id: json['id'] as int?, // 直接取整数，如果JSON中是null，这里就是null

    orderNumber: json['order_number'] as String?,

    );

    }
}